package com.luoqiz.demo.threadDemo;

public class Dome1 {
	public static void main(String[] args) {
//		test2();
		test3();
	}
	private static void test3() {
		System.out.println("*************************************************");
		System.out.println("生产者消费者测试");
		Pool p=new Pool();
//		p.setPoolMaxSize(1);	//死锁测试，设置线程最大值为1
		p.setPoolMaxSize(10);
		Productor p1=new Productor("生产者1",p);
		Consumer c1=new Consumer("消费者1",p);
		Consumer c2=new Consumer("消费者2",p);
		p1.start();
		c1.start();
		c2.start();
	}
	public static void deamonTest(){
		System.out.println("*************************************************");
		System.out.println("守护线程测试");
		Waiter w=new Waiter();
		Customer c=new Customer();
		c.start();
		//服务员为守护线程。消费者退出则进程关闭
		w.setDaemon(true);
		w.start();
	}
	
	public void threadJoinTest() {
		System.out.println("*************************************************");
		System.out.println("thread.join方法测试");
		MyThread t1 = new MyThread("thread1-");
		// MyThread t2=new MyThread("thread2-");
		t1.start();

		// t2.start();
		try {
			t1.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("main--------");

	}
}
